{{--/**
 * Created by PhpStrom
 * User: 郭碧云
 * Date: 2021/2/26 14:42
 * Desc:
 */--}}
<style>
    .layui-treeSelect{
        width: 80% !important;
    }
</style>
{{--<form id="create_from" style="display: none;margin-top: 15px;" class="layui-form">--}}
<form id="create_from" style="margin-top: 15px;" action="{{session('guard')=="system"?route('system.user.create'):route('admin.user.create')}}" class="layui-form">
    {{csrf_field()}}
    <div class="layui-form-item">
        <label class="layui-form-label">名称</label>
        <div class="layui-input-block">
            <input type="text" id="name" name="name" autocomplete="off" placeholder="名称" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-block">
            <input type="text" id="real_name" name="real_name" autocomplete="off" placeholder="姓名"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">邮箱</label>
        <div class="layui-input-block">
            <input type="email" id="email" name="email" autocomplete="off" placeholder="邮箱" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="password" id="password" name="password" autocomplete="off" placeholder="密码"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">重复密码</label>
        <div class="layui-input-block">
            <input type="password" id="password_confirmation" name="password_confirmation" autocomplete="off"
                   placeholder="重复密码" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">选择守卫</label>
        <div class="layui-input-block">
            @if(session("guard")=="admin")
                <select id="type" disabled lay-verify="required">
                    {!! Code::getOptionsByCode('GUARD','admin','--请选择--') !!}
                </select>
                <input name="guard_name" value="admin" style="display: none"/>
            @else
                <select id="type" name="guard_name" lay-verify="required">
                    {!! Code::getOptionsByCode('GUARD','','--请选择--') !!}
                </select>
            @endif
        </div>
    </div>

    @if(session('guard')!='system')
        <div class="layui-form-item">
            <label class="layui-form-label">组织机构</label>
            <div class="layui-input-block">
                <div id="orgCom" style="width: 60%"></div>
            </div>
        </div>
    @else
        <input name="org_id" value="0" style="display: none">
    @endif
</form>

<script src="{{asset('layui/modules/xm-select.js')}}"></script>
<script>
    if(guard=="admin"){
        layui.use(['xmSelect'], function () {
            let xmSelect = layui.xmSelect;
            let params=selectTreeParams('#orgCom','org_id','请选择',"",JSON.parse('{!! $orgs !!}'),function (data){
            });
            xmSelect.render(params)
        });
    }
</script>
